package com.ruoyi.hospital.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.hospital.domain.Departments;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.hospital.mapper.DoctorsMapper;
import com.ruoyi.hospital.domain.Doctors;
import com.ruoyi.hospital.service.IDoctorsService;

/**
 * 医生信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@Service
public class DoctorsServiceImpl implements IDoctorsService
{
    @Autowired
    private DoctorsMapper doctorsMapper;




    @Autowired
    private DepartmentsServiceImpl departmentsService;


    /**
     * 查询医生信息
     *
     * @param doctorId 医生信息主键
     * @return 医生信息
     */


    /**
     * 查询医生信息列表
     *
     * @param doctors 医生信息
     * @return 医生信息
     */
    @Override
    public List<Doctors> selectDoctorsList(Doctors doctors)
    {
        return doctorsMapper.selectDoctorsList(doctors);
    }

    /**
     * 新增医生信息
     *
     * @param doctors 医生信息
     * @return 结果
     */
    @Override
    public int insertDoctors(Doctors doctors)
    {
        doctors.setCreateTime(DateUtils.getNowDate());
        return doctorsMapper.insertDoctors(doctors);
    }

    @Override
    public Doctors selectDoctorsByDoctorId(Long doctorId) {
        return doctorsMapper.selectDoctorsByDoctorId(doctorId);
    }

    /**
     * 修改医生信息
     *
     * @param doctors 医生信息
     * @return 结果
     */
    @Override
    public int updateDoctors(Doctors doctors)
    {
        doctors.setUpdateTime(DateUtils.getNowDate());
        return doctorsMapper.updateDoctors(doctors);
    }

    /**
     * 批量删除医生信息
     *
     * @param doctorIds 需要删除的医生信息主键
     * @return 结果
     */
    @Override
    public int deleteDoctorsByDoctorIds(Long[] doctorIds)
    {
        return doctorsMapper.deleteDoctorsByDoctorIds(doctorIds);
    }

    /**
     * 删除医生信息信息
     *
     * @param doctorId 医生信息主键
     * @return 结果
     */
    public int deleteDoctorsByDoctorId(Long doctorId)
    {
        return doctorsMapper.deleteDoctorsByDoctorId(doctorId);
    }


    @Override
public List<Doctors> getDoctorsByDeptName(String deptName){
        Departments departments=departmentsService.getOne(new QueryWrapper<Departments>().eq("dept_name",deptName));
       List<Doctors> doctors=doctorsMapper.getDoctorsByDeptId(departments.getDeptId());
        return doctors;

}

}
